home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / CUCD / Programming / SWI / source / src / test / lwrcase.c next >
Encoding:
C/C++ Source or Header  |  1996-01-22  |  773 b   |  43 lines

  1. /*  $Id: lwrcase.c,v 1.5 1996/01/22 15:26:17 jan Exp $
  2.  
  3.     Designed and implemented by Jan Wielemaker
  4.     E-mail: jan@swi.psy.uva.nl
  5.  
  6.     Copyright (C) 1994 University of Amsterdam. All rights reserved.
  7.     Purpose: test load_foreign and friends
  8. */
  9.  
  10. #include <SWI-Prolog.h>
  11. #include <ctype.h>
  12.  
  13. foreign_t
  14. pl_lowercase(term_t u, term_t l)
  15. { char *copy;
  16.   char *s, *q;
  17.   atom_t la;
  18.  
  19.   if ( !PL_get_atom_chars(u, &s) )
  20.     return PL_warning("lowercase/2: instantiation fault");
  21.   copy = malloc(strlen(s)+1);
  22.  
  23.   for( q=copy; *s; q++, s++)
  24.     *q = (isupper(*s) ? tolower(*s) : *s);
  25.   *q = '\0';
  26.  
  27.   la = PL_new_atom(copy);
  28.   free(copy);
  29.  
  30.   return PL_unify_atom(l, la);
  31. }
  32.  
  33. install_t
  34. install()
  35. { PL_register_foreign("lowercase", 2, pl_lowercase, 0);
  36. }
  37.  
  38.  
  39. install_t
  40. uninstall()
  41. {
  42. }
  43.